-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support getting caller and group information from multiple tokens #26719
support getting caller and group information from multiple tokens #26719
Conversation
#build |
Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_-fsC4HLdEe6LyICjST0JEw Target locations of links might be accessible only to IBM employees. |
88c6bc8
to
f876e18
Compare
The build arunavemulapalli-26719-20231024-2038 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_-fsC4HLdEe6LyICjST0JEw |
The build arunavemulapalli-26719-2-20231025-1441 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_tPX1kHN1Ee6LyICjST0JEw |
#libby |
1189bff
to
bf4e530
Compare
The build arunavemulapalli-26719-2-20231028-1555 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_Vwua0HXbEe6p7N33NVgeoQ |
The build arunavemulapalli-26719-2-20231031-2120 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_RQ_MMHhkEe6p7N33NVgeoQ |
a48f897
to
6f189a7
Compare
#libby |
The build arunavemulapalli-26719-2-20231106-1602 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_XffuwHz3Ee6pmuZkFgD-jA |
6f189a7
to
e1607c0
Compare
#libby |
e1607c0
to
a9709b9
Compare
… token, access token, user info address review comments social - OidcLoginConfigImpl update Fix the groupId / aud retrieval issue configuration update configuration update and add implementation to OidcLoginConfigImpl Update to ignore the exception from finding userinfo and continue with the other 2 tokens Update to use space instead of "," to fix the configuration issue update to take default value when the new config attribute is not used
The build arunavemulapalli-26719-2-20231107-2016 |
L2 message review not required. |
#libby |
@@ -562,7 +567,14 @@ private void processConfigProps(Map<String, Object> props) { | |||
// checkValidationEndpointUrl(); | |||
|
|||
// validateAuthzTokenEndpoints(); //TODO: update tests to expect the error if the validation here fails | |||
|
|||
String tokens = configUtils.getConfigAttributeWithDefaultValue(props, CFG_KEY_TOKEN_ORDER_TOFETCH_CALLER_CLAIMS, "IDToken");//getStringArrayConfigAttribute(props, CFG_KEY_TOKEN_ORDER_TOFETCH_CALLER_CLAIMS); | |||
/* if (tokens == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean up code
@@ -298,3 +298,8 @@ pkceCodeChallengeMethod.S256=S256 | |||
|
|||
tokenRequestOriginHeader=Token request origin header | |||
tokenRequestOriginHeader.desc=Specifies the value to use in the Origin HTTP header that is included in the HTTP POST request to the token endpoint of the OpenID Connect provider. If not specified, an Origin HTTP header is not included in the request. | |||
|
|||
tokenOrderToFetchCallerClaims=Specify one or more tokens to fetch caller claims | |||
tokenOrderToFetchCallerClaims.desc=Specifies the order of the token/s to fetch the caller name and group claim values. If the claim does not exist in the first token, then the OpenID Connect client will continue the search with other tokens in the list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove /
change "will continue" to "continues"
tokenOrderToFetchCallerClaims=Specify one or more tokens to fetch caller claims | ||
tokenOrderToFetchCallerClaims.desc=Specifies the order of the token/s to fetch the caller name and group claim values. If the claim does not exist in the first token, then the OpenID Connect client will continue the search with other tokens in the list | ||
tokenOrderToFetchCallerClaims.IDToken=Use IDToken only to determine the caller claims | ||
tokenOrderToFetchCallerClaims.ACCESSAndIDAndUITokens=Use AccessToken, IDToken and Userinfo tokens in this order, to determine the caller claims. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses the AccessToken, IDToken, and UserInfo tokens, in that order, to determine the caller claims.
|
||
tokenOrderToFetchCallerClaims=Specify one or more tokens to fetch caller claims | ||
tokenOrderToFetchCallerClaims.desc=Specifies the order of the token/s to fetch the caller name and group claim values. If the claim does not exist in the first token, then the OpenID Connect client will continue the search with other tokens in the list | ||
tokenOrderToFetchCallerClaims.IDToken=Use IDToken only to determine the caller claims |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses only the IDToken to determine the caller claims
|
||
public static final String USER_PRINCIPAL_NAME = "upn"; | ||
|
||
public static final String GROUP = "groupIds"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to call this GROUP_IDS
instead of GROUP
?
@@ -40,6 +40,7 @@ public class TokenEndpointServlet extends HttpServlet { | |||
private static final long serialVersionUID = 1L; | |||
private final String servletName = "TokenEndpointServlet"; | |||
private String token = null; | |||
private String idt = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would really prefer this to be called something like overrideIdToken
or idTokenOverride
or idTokenRequestParameter
so it's more descriptive than the cryptic idt
.
trustAliasName="rs256" | ||
signatureAlgorithm="RS256" | ||
tokenOrderToFetchCallerClaims="AccessToken IDToken Userinfo" | ||
mapIdentityToRegistryUser="yes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapIdentityToRegistryUser
takes a boolean as a value, so the value needs to either be "true"
or "false"
.
com.ibm.ws.webcontainer.security.*=all=enabled:\ | ||
com.ibm.oauth.*=all=enabled:\ | ||
com.ibm.wsspi.security.oauth20.*=all=enabled:\ | ||
org.apache.http.client.*=all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also add io.openliberty.security*=all
.
com.ibm.ws.webcontainer.security.*=all=enabled:\ | ||
com.ibm.oauth.*=all=enabled:\ | ||
com.ibm.wsspi.security.oauth20.*=all=enabled:\ | ||
org.apache.http.client.*=all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add io.openliberty.security*=all
.
userInfoClaims = getClaimsFromUserInfo(userInfoStr); | ||
|
||
} catch (Exception e) { | ||
Tr.error(tc, "Invalid user info: " + userInfoStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tr.error(tc, "Invalid user info: " + userInfoStr); | |
Tr.debug(tc, "Invalid user info: " + userInfoStr); |
The Tr.error()
method emits messages to the console.log and messages.log that require translation. The Tr.debug()
method should be used here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a higher priority issue to fix.
oidcResult = new ProviderAuthenticationResult(AuthResult.SUCCESS, HttpServletResponse.SC_OK, null, null, props, null); | ||
if (isRunningBetaMode()) { | ||
createWASOidcSession(oidcClientRequest, jwtClaims, clientConfig); | ||
//createWASOidcSession(oidcClientRequest, jwtClaims, clientConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code.
uid = clientConfig.getUserIdentityToCreateSubject(); | ||
} | ||
|
||
String[] userClaimIdentifiers = {attrUsedToCreateSubject, uid}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't an ideal way to return data back from the method. It's not clear to callers that [0]
happens to be the name of the attribute name and [1]
happens to be the value.
@SuppressWarnings("unchecked") | ||
List<String> getGroupIds(ConvergedClientConfig clientConfig, List<String> tokensOrderToFetchCallerClaims, Map<String, JwtClaims> tokenClaimsMap) throws MalformedClaimException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SuppressWarnings("unchecked") | |
List<String> getGroupIds(ConvergedClientConfig clientConfig, List<String> tokensOrderToFetchCallerClaims, Map<String, JwtClaims> tokenClaimsMap) throws MalformedClaimException { | |
@SuppressWarnings("unchecked") | |
@FFDCIgnore(MalformedClaimException.class) | |
List<String> getGroupIds(ConvergedClientConfig clientConfig, List<String> tokensOrderToFetchCallerClaims, Map<String, JwtClaims> tokenClaimsMap) throws MalformedClaimException { |
List<String> groupIds = null; | ||
try { | ||
groupIds = getClaimValueFromTokens(groupIdsClaim, List.class, tokensOrderToFetchCallerClaims, tokenClaimsMap); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (Exception e) { | |
} catch (MalformedClaimException e) { |
thanks @ayoho , @arkarkala for the review. I will get the review issues done |
a9709b9
to
ee5dcdd
Compare
#build |
Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_yOrhMH_3Ee6pmuZkFgD-jA Target locations of links might be accessible only to IBM employees. |
#libby |
Code analysis and actionsDO NOT DELETE THIS COMMENT.
|
The build arunavemulapalli-26719-20231110-1143 For help analyzing your personal build, go to https://libh-proxy1.fyre.ibm.com/cognitive/buildAnalysis.html?uuid=_yOrhMH_3Ee6pmuZkFgD-jA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -298,3 +298,8 @@ pkceCodeChallengeMethod.S256=S256 | |||
|
|||
tokenRequestOriginHeader=Token request origin header | |||
tokenRequestOriginHeader.desc=Specifies the value to use in the Origin HTTP header that is included in the HTTP POST request to the token endpoint of the OpenID Connect provider. If not specified, an Origin HTTP header is not included in the request. | |||
|
|||
tokenOrderToFetchCallerClaims=Specify one or more tokens to fetch caller claims |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change is fine
update oidc client config, runtime
For #25460
Fixes #26888